<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.GregorianCalendar"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.json.simple.JSONArray"%>
<%@page import="java.util.Arrays"%>
<%@page import="dongbu.bo.overtime.OverTimeBO"%>
<%@page import="dongbu.vo.overtime.OverTimeChild"%>
<%@page import="java.net.URLEncoder"%>
<%
	request.setCharacterEncoding("UTF-8");
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

	//이번달 시작 ~ 종료까지 해당 value생성
	GregorianCalendar today = new GregorianCalendar();
	int minday = today.getActualMinimum(GregorianCalendar.DAY_OF_MONTH);
	int maxday = today.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
	
	OverTimeBO bo = new OverTimeBO();
	List list = bo.getOverTimeChildList();
	List eventList = new ArrayList();
	
	for (int i = 0; i < list.size(); i++) {
		today.set(Calendar.DAY_OF_MONTH, today.getActualMinimum(GregorianCalendar.DAY_OF_MONTH));
		OverTimeChild child = (OverTimeChild)list.get(i);
		
		for (int j = minday; j <= maxday; j++) {
			int day_of_week = today.get(Calendar.DAY_OF_WEEK);
			if(day_of_week != 1 & day_of_week != 7){
				Map info = new HashMap();
				info.put("title", 	"'" + child.getName() + "'");
				info.put("start", 	"'" + sdf.format(today.getTime()) + " 09:00'");
				info.put("end", 	"'" + sdf.format(today.getTime()) + " 20:50'");
				info.put("allDay", 	false);
				info.put("id", 	"'" + (i+1)+""+j +"'");
				
				eventList.add(info);
			}
			
			if(j < maxday)
				today.add(Calendar.DAY_OF_MONTH, 1);
		}
	}
	
	JSONArray jsonArray = new JSONArray();
	String eventString = jsonArray.toJSONString(eventList);
	eventString = eventString.replace("'", "");
	response.setCharacterEncoding("UTF-8");
	response.getWriter().write(eventString);
%>